#!/usr/bin/env python
# coding: utf-8
# Date  : 2018-08-28 13:40:08
# Author: dazhong
# Email : 88350676@qq.com
# Func  :
import os
BASE_DIR =os.path.abspath(os.path.dirname(__file__))

AUTHSERVER_GATEWAY_IP = '192.168.1.254'
#身份证省份配置
DISTRICTLIST = ["11", "12", "13", "14", "15", "21", "22", "23", "31", "32", "33", "34", "35", "36", "37",
                    "41", "42", "43", "44", "45", "46", "50", "51", "52", "53", "54", "61", "62", "63", "64",
                    "65", "71", "81", "82"]

USERNAME='admin'
PASSWORD='crf123'

#银行列表配置
BANK_LIST={
    '光大银行':{
        'prefix':'621492',
        'len':16
    },
    '平安银行':{
        'prefix':'622298',
        'len':19
    },
    '工商银行':{
        'prefix':'621558',
        'len':19
    },
    '广发银行':{
        'prefix':'621462',
        'len':19
    },
    '农业银行':{
        'prefix':'622848',
        'len':19
    },
    '兴业银行':{
        'prefix':'622908',
        'len':19
    },
    '邮政银行':{
        'prefix':'622151',
        'len':19
    },
    '招商银行':{
        'prefix':'621485',
        'len':16
    },
    '中国银行':{
        'prefix':'621661',
        'len':19
    },
    '中信银行':{
        'prefix':'621771',
        'len':16
    },
    '建设银行':{
        'prefix':'621700',
        'len':19
    },
    '华夏银行':{
        'prefix':'622630',
        'len':16
    },
    '浦发银行':{
        'prefix':'621792',
        'len':16
    },
    '民生银行':{
        'prefix':'622622',
        'len':16
    },


}
#环境列表配置，如果环境扩展了，请添加此配置即可
EN_LIST = {'UAT', 'UATA', 'BRUAT', 'CI', 'BRDEV'}
#数据库列表配置，如果有新的数据库，请加入此列表，同时在环境详细配置中进行关联配置
DB_LIST={
    'db_uat1':{
        "DBHOST": "192.168.70.3",
        "DBUSER": "user_test",
        "DBPWD": "1107",
        "DBPORT": 3306,
        'DBNAME':'',
        'DBCHAR':'utf8'
    },
    'db_uat2':{
        "DBHOST":"192.168.90.111",
        "DBUSER":"user_test",
        "DBPWD":"1107",
        "DBPORT":3307,
        'DBNAME':'',
        'DBCHAR':'utf8'
    }
}
#redis列表配置，如果有新的redis，请加入此列表，同时在环境详细配置中进行关联配置
REDIS_LIST={
    'redis_1':{
        "ip": "10.194.80.12",
        "password": "",
        "port": 6379
    },
    'redis_2':{
        "ip": "192.168.60.99",
        "password": "123456",
        "port": 6395
    },
    'redis_3': {
        "ip": "192.168.60.99",
        "password": "",
        "port": 6390
    },
    'redis_4': {
        "ip": "192.168.70.3",
        "password": "",
        "port": 6423
    },
    'redis_5': {
        "ip": "192.168.70.3",
        "password": "",
        "port": 6380
    },
}
#环境变量详细配置，映射各功能对应的数据库、地址、redis、表名称等内容
ENV_LIST = {
    'UAT':{
        'url_crm':'http://crfcrm-uat.crf.com',
        'url_app':'https://app-uat.crfchina.com',
        'url_h5':'https://m-uat.crfchina.com',
        'url_rcs_rcsmgr':'http://rcsmgr-uat.crfchina.com',
        'url_passport':'https://passport-uat.crfchina.com',
        'consumption_callback_url':'https://m-uat.crfchina.com',
        'redis_app':{
            'redis_name':'redis_1',
            'redis_index':15
        },
        'redis_fts':{
            'redis_name':'redis_2',
            'redis_index':0
        },
        'redis_auth_server':{
            'redis_name':'redis_1',
            'redis_index':15
        },
        'redis_fcp2':{
            'redis_name':'redis_3',
            'redis_index':0
        },
        'redis_crm':{
            'redis_name':'redis_4',
            'redis_index':0
        },
        'redis_fts2':{
            'redis_name':'redis_5',
            'redis_index':0
        },
        'sms_platform':{
            'table_name':'uat_sms_platform',
            'db_name':'db_uat1'
        },
        'afdb': {
            'table_name': 'afdbcrf_rcs_core_db_uat',
            'db_name': 'db_uat1'
        },
        'crf_crm': {
            'table_name': 'crf_crm',
            'db_name': 'db_uat1'
        },
        'mobile_loan': {
            'table_name': 'mobile_loan',
            'db_name': 'db_uat1'
        },
        'crf_rcs_agent_db': {
            'table_name': 'crf_rcs_agent_db_uat',
            'db_name': 'db_uat2'
        },
        'crf_rcs_core_db': {
            'table_name': 'crf_rcs_core_db_uat',
            'db_name': 'db_uat2'
        },
        'ngcc_ipp_zh': {
            'table_name': 'ngcc_ipp_zh_uat',
            'db_name': 'db_uat1'
        },
        'fts2db': {
            'table_name': 'fts2db_uat',
            'db_name': 'db_uat1'
        },
        'ftsdb': {
            'table_name': 'ftsdb_uat',
            'db_name': 'db_uat1'
        },
        'fcpdb': {
            'table_name': 'fcp2db_uat',
            'db_name': 'db_uat1'
        },
        'kisso': {
            'table_name': 'kisso',
            'db_name': 'db_uat1'
        },
        'app_db': {
            'table_name': 'app_db_uat',
            'db_name': 'db_uat1'
        },
        'promotion': {
            'table_name': 'promotion_uat',
            'db_name': 'db_uat1'
        },
        'crf_consumption_loan': {
            'table_name': 'crf_consumption_loan',
            'db_name': 'db_uat1'
        },
    },
    'UATA':{
        'url_crm':'http://crfcrm-uat.crf.com',
        'url_app':'https://app-uat.crfchina.com',
        'url_h5':'https://m-uat.crfchina.com',
        'url_rcs_rcsmgr':'http://rcsmgr-uat.crfchina.com',
        'url_passport':'https://passport-uat.crfchina.com',
        'consumption_callback_url':'https://m-uat.crfchina.com',
        'redis_app':{
            'redis_name':'redis_1',
            'redis_index':15
        },
        'redis_fts':{
            'redis_name':'redis_2',
            'redis_index':0
        },
        'redis_auth_server':{
            'redis_name':'redis_1',
            'redis_index':15
        },
        'redis_fcp2':{
            'redis_name':'redis_3',
            'redis_index':0
        },
        'redis_crm':{
            'redis_name':'redis_4',
            'redis_index':0
        },
        'redis_fts2':{
            'redis_name':'redis_5',
            'redis_index':0
        },
        'sms_platform':{
            'table_name':'uat_sms_platform',
            'db_name':'db_uat1'
        },
        'afdb': {
            'table_name': 'crf_crm',
            'db_name': 'db_uat1'
        },
        'mobile_loan': {
            'table_name': 'mobile_loan',
            'db_name': 'db_uat1'
        },
        'crf_rcs_agent_db': {
            'table_name': 'crf_rcs_agent_db_uat',
            'db_name': 'db_uat2'
        },
        'crf_rcs_core_db': {
            'table_name': 'crf_rcs_core_db_uat',
            'db_name': 'db_uat2'
        },
        'ngcc_ipp_zh': {
            'table_name': 'ngcc_ipp_zh_uat',
            'db_name': 'db_uat1'
        },
        'fts2db': {
            'table_name': 'fts2db_uat',
            'db_name': 'db_uat1'
        },
        'fcpdb': {
            'table_name': 'fcp2db_uat',
            'db_name': 'db_uat1'
        },
        'kisso': {
            'table_name': 'kisso',
            'db_name': 'db_uat1'
        },
        'app_db': {
            'table_name': 'app_db_uat',
            'db_name': 'db_uat1'
        },
        'promotion': {
            'table_name': 'promotion_uat',
            'db_name': 'db_uat1'
        },
        'crf_consumption_loan': {
            'table_name': 'crf_consumption_loan',
            'db_name': 'db_uat1'
        },
    },
    'BRUAT':{
        'url_crm':'http://crfcrm-uat.crf.com',
        'url_app':'https://app-uat.crfchina.com',
        'url_h5':'https://m-uat.crfchina.com',
        'url_rcs_rcsmgr':'http://rcsmgr-uat.crfchina.com',
        'url_passport':'https://passport-uat.crfchina.com',
        'consumption_callback_url':'https://m-uat.crfchina.com',
        'redis_app':{
            'redis_name':'redis_1',
            'redis_index':15
        },
        'redis_fts':{
            'redis_name':'redis_2',
            'redis_index':0
        },
        'redis_auth_server':{
            'redis_name':'redis_1',
            'redis_index':15
        },
        'redis_fcp2':{
            'redis_name':'redis_3',
            'redis_index':0
        },
        'redis_crm':{
            'redis_name':'redis_4',
            'redis_index':0
        },
        'redis_fts2':{
            'redis_name':'redis_5',
            'redis_index':0
        },
        'sms_platform':{
            'table_name':'uat_sms_platform',
            'db_name':'db_uat1'
        },
        'afdb': {
            'table_name': 'crf_crm',
            'db_name': 'db_uat1'
        },
        'mobile_loan': {
            'table_name': 'mobile_loan',
            'db_name': 'db_uat1'
        },
        'crf_rcs_agent_db': {
            'table_name': 'crf_rcs_agent_db_uat',
            'db_name': 'db_uat2'
        },
        'crf_rcs_core_db': {
            'table_name': 'crf_rcs_core_db_uat',
            'db_name': 'db_uat2'
        },
        'ngcc_ipp_zh': {
            'table_name': 'ngcc_ipp_zh_uat',
            'db_name': 'db_uat1'
        },
        'fts2db': {
            'table_name': 'fts2db_uat',
            'db_name': 'db_uat1'
        },
        'fcpdb': {
            'table_name': 'fcp2db_uat',
            'db_name': 'db_uat1'
        },
        'kisso': {
            'table_name': 'kisso',
            'db_name': 'db_uat1'
        },
        'app_db': {
            'table_name': 'app_db_uat',
            'db_name': 'db_uat1'
        },
        'promotion': {
            'table_name': 'promotion_uat',
            'db_name': 'db_uat1'
        },
        'crf_consumption_loan': {
            'table_name': 'crf_consumption_loan',
            'db_name': 'db_uat1'
        },
    },
    'CI':{
        'url_crm':'http://crfcrm-uat.crf.com',
        'url_app':'https://app-uat.crfchina.com',
        'url_h5':'https://m-uat.crfchina.com',
        'url_rcs_rcsmgr':'http://rcsmgr-uat.crfchina.com',
        'url_passport':'https://passport-uat.crfchina.com',
        'consumption_callback_url':'https://m-uat.crfchina.com',
        'redis_app':{
            'redis_name':'redis_1',
            'redis_index':15
        },
        'redis_fts':{
            'redis_name':'redis_2',
            'redis_index':0
        },
        'redis_auth_server':{
            'redis_name':'redis_1',
            'redis_index':15
        },
        'redis_fcp2':{
            'redis_name':'redis_3',
            'redis_index':0
        },
        'redis_crm':{
            'redis_name':'redis_4',
            'redis_index':0
        },
        'redis_fts2':{
            'redis_name':'redis_5',
            'redis_index':0
        },
        'sms_platform':{
            'table_name':'uat_sms_platform',
            'db_name':'db_uat1'
        },
        'afdb': {
            'table_name': 'crf_crm',
            'db_name': 'db_uat1'
        },
        'mobile_loan': {
            'table_name': 'mobile_loan',
            'db_name': 'db_uat1'
        },
        'crf_rcs_agent_db': {
            'table_name': 'crf_rcs_agent_db_uat',
            'db_name': 'db_uat2'
        },
        'crf_rcs_core_db': {
            'table_name': 'crf_rcs_core_db_uat',
            'db_name': 'db_uat2'
        },
        'ngcc_ipp_zh': {
            'table_name': 'ngcc_ipp_zh_uat',
            'db_name': 'db_uat1'
        },
        'fts2db': {
            'table_name': 'fts2db_uat',
            'db_name': 'db_uat1'
        },
        'fcpdb': {
            'table_name': 'fcp2db_uat',
            'db_name': 'db_uat1'
        },
        'kisso': {
            'table_name': 'kisso',
            'db_name': 'db_uat1'
        },
        'app_db': {
            'table_name': 'app_db_uat',
            'db_name': 'db_uat1'
        },
        'promotion': {
            'table_name': 'promotion_uat',
            'db_name': 'db_uat1'
        },
        'crf_consumption_loan': {
            'table_name': 'crf_consumption_loan',
            'db_name': 'db_uat1'
        },
    },
    'BRDEV':{
        'url_crm':'http://crfcrm-uat.crf.com',
        'url_app':'https://app-uat.crfchina.com',
        'url_h5':'https://m-uat.crfchina.com',
        'url_rcs_rcsmgr':'http://rcsmgr-uat.crfchina.com',
        'url_passport':'https://passport-uat.crfchina.com',
        'consumption_callback_url':'https://m-uat.crfchina.com',
        'redis_app':{
            'redis_name':'redis_1',
            'redis_index':15
        },
        'redis_fts':{
            'redis_name':'redis_2',
            'redis_index':0
        },
        'redis_auth_server':{
            'redis_name':'redis_1',
            'redis_index':15
        },
        'redis_fcp2':{
            'redis_name':'redis_3',
            'redis_index':0
        },
        'redis_crm':{
            'redis_name':'redis_4',
            'redis_index':0
        },
        'redis_fts2':{
            'redis_name':'redis_5',
            'redis_index':0
        },
        'sms_platform':{
            'table_name':'uat_sms_platform',
            'db_name':'db_uat1'
        },
        'afdb': {
            'table_name': 'crf_crm',
            'db_name': 'db_uat1'
        },
        'mobile_loan': {
            'table_name': 'mobile_loan',
            'db_name': 'db_uat1'
        },
        'crf_rcs_agent_db': {
            'table_name': 'crf_rcs_agent_db_uat',
            'db_name': 'db_uat2'
        },
        'crf_rcs_core_db': {
            'table_name': 'crf_rcs_core_db_uat',
            'db_name': 'db_uat2'
        },
        'ngcc_ipp_zh': {
            'table_name': 'ngcc_ipp_zh_uat',
            'db_name': 'db_uat1'
        },
        'fts2db': {
            'table_name': 'fts2db_uat',
            'db_name': 'db_uat1'
        },
        'fcpdb': {
            'table_name': 'fcp2db_uat',
            'db_name': 'db_uat1'
        },
        'kisso': {
            'table_name': 'kisso',
            'db_name': 'db_uat1'
        },
        'app_db': {
            'table_name': 'app_db_uat',
            'db_name': 'db_uat1'
        },
        'promotion': {
            'table_name': 'promotion_uat',
            'db_name': 'db_uat1'
        },
        'crf_consumption_loan': {
            'table_name': 'crf_consumption_loan',
            'db_name': 'db_uat1'
        },
    }

}
#配置会员信息
MEMBER_LIST={
    '黄金年卡':{
        'member_name':'黄金会员',
        'member_type':'1',
        'member_days':365,
        'member_amount':'12800.00',
        'member_product':'P6000001'
    },
    '白金年卡':{
        'member_name':'白金会员',
        'member_type':'2',
        'member_days':365,
        'member_amount':'19800.00',
        'member_product':'P6000002'
    },
    '钻石年卡':{
        'member_name':'钻石会员',
        'member_type':'3',
        'member_days':365,
        'member_amount':'39800.00',
        'member_product':'P6000003'
    },
    '黄金季卡':{
        'member_name':'黄金会员',
        'member_type':'1',
        'member_days':90,
        'member_amount':'12800.00',
        'member_product':'P600J001'
    },
    '白金季卡':{
        'member_name':'白金会员',
        'member_type':'2',
        'member_days':90,
        'member_amount':'19800.00',
        'member_product':'P600J002'
    },
    '钻石季卡':{
        'member_name':'钻石会员',
        'member_type':'3',
        'member_days':90,
        'member_amount':'39800.00',
        'member_product':'P600J003'
    },
    '黄金体验卡':{
        'member_name':'黄金会员',
        'member_type':'1',
        'member_days':90,
        'member_amount':'12800.00',
        'member_product':'P6000004'
    },
    '白金体验卡':{
        'member_name':'白金会员',
        'member_type':'2',
        'member_days':90,
        'member_amount':'19800.00',
        'member_product':'P6000005'
    },
    '钻石体验卡':{
        'member_name':'钻石会员',
        'member_type':'3',
        'member_days':90,
        'member_amount':'39800.00',
        'member_product':'P6000006'
    },
    '信而富148黄金体验卡':{
        'member_name':'黄金会员',
        'member_type':'1',
        'member_days':90,
        'member_amount':'19800.00',
        'member_product':'P6000011'
    }


}

def get_dbinfo(name, env):
    if name is None or name == '':
        return None
    if env is None or env == '':
        return None
    dbinfo = ENV_LIST.get(env)
    if dbinfo is None:
        return None
    dbinfo = dbinfo.get(name)
    return dbinfo

def _init():
    global _global_db_dict,_global_redis_dict
    _global_db_dict = {}
    _global_redis_dict={}

def set_db_value(name, value):
    _global_db_dict[name] = value

def get_db_value(name, defValue=None):
    try:
        return _global_db_dict.get(name)
    except KeyError:
        return defValue
def set_redis_value(name, value):
    _global_redis_dict[name] = value

def get_redis_value(name, defValue=None):
    try:
        return _global_redis_dict.get(name)
    except KeyError:
        return defValue